home *** CD-ROM | disk | FTP | other *** search
/ World of Amiga / World of Amiga.iso / archive / compression / lister12.lha / ListLharc.c < prev    next >
Encoding:
Text File  |  1992-04-01  |  1.5 KB  |  63 lines

  1. /* List an Lharc file's contents */
  2. BOOL
  3. ListLharc(ULONG type,UBYTE *infile)
  4. {
  5.   int ct, time, date, done;
  6.   ULONG uncomp, comp;
  7.   UBYTE name[200],b[200],time_str[25];
  8.   FILE *fp;
  9.   ULONG tfiles = 0, tcomp = 0, tuncomp = 0;
  10.  
  11.   fp = OpenFile(type,infile);
  12.  
  13.   /* Read in my bytes */
  14.   ReadBuf (22,fp,b);
  15.  
  16.   /* Determine if it is an Lharc file */
  17.   if ((strncmp(b+(sizeof (char) *2),"-l",2) != 0))
  18.     {
  19.       fclose (fp);
  20.       return (WRONG_ARCHIVE);
  21.     }
  22.  
  23.   /* It is an Lharc file.  Is it the NEW LH5 format? */
  24.   if ((strncmp(b+(sizeof (char) *2),"-lh5",4) == 0))
  25.     type = LHA;
  26.  
  27.   /* Get file name stored in archive */
  28.   fread(name,b[21]+2,1,fp);
  29.   name[b[21]] = 0;
  30.  
  31.   /* Print out header info to standard output */
  32.   if (type != LHA) type = LHARC;
  33.   InitList(type,infile);
  34.  
  35.   done = FALSE;
  36.   while (!done)
  37.    {
  38.      /* Calculate Compressed, Uncompressed, Date,Time, and print it out */
  39.      comp = GetLong(b,10);
  40.      uncomp = GetLong(b,14);
  41.      date = b[18] * 256 + b[17];
  42.      time = b [16] * 256 + b[15];
  43.      if (MSDog (time,date,time_str) == ABORT) break;
  44.      PrintList(name, uncomp, comp,&tfiles,&tcomp,&tuncomp,time_str);
  45.  
  46.      /* Read in more bytes */
  47.      fseek(fp,comp,SEEK_CUR);
  48.      ct = fread(b,22,1,fp);
  49.  
  50.      if ((strncmp(b+(sizeof (char) *2),"-l",2) != 0) || (ct < 1))
  51.        done = TRUE;
  52.  
  53.      /* Read in file name again */
  54.      fread(name,b[21]+2,1,fp);
  55.      name[b[21]] = 0;
  56.    }
  57.  
  58.   fclose (fp);
  59.   /* Print ending stats */
  60.   EndStats(tfiles,tcomp,tuncomp);
  61.   return (TRUE);
  62. }
  63.